package com.sh.data.engine.common.enumDefinition;

import java.util.Objects;

/**
 * @author tinglan.ys
 * @description:
 * @date 2022/2/24 下午4:28
 */
public enum TaskScheduleCycle {
    month(0, "月"),
    week(1, "周"),
    day(2, "天"),
    hour(3, "小时"),
    minute(4, "分钟"),
    ;

    private int key;
    private String name;

    TaskScheduleCycle(int key, String name) {
        this.key = key;
        this.name = name;
    }

    public int getKey() {
        return this.key;
    }

    public String getName() {
        return name;
    }

    public static TaskScheduleCycle getByCode(int code) {
        for (TaskScheduleCycle value : TaskScheduleCycle.values()) {
            if (Objects.equals(value.key, code)) {
                return value;
            }
        }
        return null;
    }
}
